package com.qiezi.bean;

import com.alibaba.fastjson.annotation.JSONField;

import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

public class DataBean<T> {
    private ArrayList<T> list;
    private ArrayList<String> banner;

    @JSONField(name = "is_open")
    private boolean open;

    private long endtime;
    private String strEndTime;
    private static SimpleDateFormat sdf = new SimpleDateFormat("将于 yyyy-MM-dd HH:mm:ss 到期");


    public boolean isOpen() {
        return open;
    }

    public void setOpen(boolean open) {
        this.open = open;
    }

    public String getEndtime() {
        return strEndTime;
    }

    public void setEndtime(long endtime) {
        this.endtime = endtime;
        strEndTime = sdf.format(new Date(endtime));
    }

    public ArrayList<T> getList() {
        return list;
    }

    public void setList(ArrayList<T> list) {
        this.list = list;
    }

    public ArrayList<String> getBanner() {
        return banner;
    }

    public void setBanner(ArrayList<String> banner) {
        ArrayList<String> l = new ArrayList<>();
        for (int i = 0;i<banner.size();i++){
            l.add(VideoBean.URL+banner.get(i));
        }
        this.banner = l;
    }

    @Override
    public String toString() {
        StringBuilder str = new StringBuilder("\n\t\tlist:").append(list.toString())
                .append("\n\t\tbanner:").append(banner==null?"":getBanner().toString())
                .append("\n\t\tstrEndTime:").append(strEndTime==null?"":strEndTime)
                .append("\n\t\topen:").append(open);

        return str.toString();
    }
}
